<template>
    <view class="content uni-flex">
        <view class="input-group">			
            <view class="input-row border">
                <text class="title width-auto">服务器地址：</text>
                <input class="width-a100" type="text" v-model="website" placeholder="请输入">
            </view>
        </view>
        <view class="btn-row">
            <button type="primary" class="primary" @tap="confirm">确定</button>
        </view>

    </view>
</template>

<script>
    import service from '../../service.js';

    export default {
        data() {
            return {
                website: '',
				oldVal: ''
            }
        },
		onLoad() {
			this.website = service.getWebsite();
			this.oldVal = this.website;
		},
        methods: {
            confirm() {
				
				service.setWebsite(this.website);
				
				let user = service.getUsers();
				if(this.oldVal == this.website) {
					uni.navigateBack({ delta: 1 });
				}else {
					uni.showModal({
						title: '提示',
						content: '地址已改变，请重新登录',
						showCancel: false,
						success: (res) => {
							if (res.confirm) {
								service.logout();
								uni.reLaunch({ url: '../login/login' });
							}
						}
					});
				}
            }
        }
    }
</script>

<style>

	.input-row {
		min-height:100rpx;
		align-items:center;
	}
	
	.input-row .title {
		width: auto;
	}
	
	.input-row input {
		width:100%;
	}
	.right-label {
		margin-left: 50upx;
	}
	
	.input-row label, .input-row input {
		color: #777777;
	}

</style>
